<?php
	//任务管理类
	class Mission extends BaseLogic{
		protected $verify;
		function __construct($showError=TRUE){
			parent:: __construct($showError);
			$this->verify=new Verify();
			$this->tabName = TAB_PREFIX."mission";
			$this->fieldList=Array("mid", "title", "murl", "amount", "remain", "pay", "mcontent", "mrequire", "ipable", "ctime", "etime", "state");
		}
		
		function getMission($id){
			$sqlwhere="mid".$this->sqlWhere($id);;
			return $this->get($sqlwhere);
		}
		
		function addMission($postList){
			$post["ctime"]=time();
			$post['title']=stripslashes($post['title']);
			$post['murl']=stripslashes($post['murl']);
			$post['mcontent']=stripslashes($post['mcontent']);
			$post['mrequire']=stripslashes($post['mrequire']);
			if($this->add($post)){
				$this->messList[]="任务生成成功！";
				return true;
			}else{
				$this->messList[]="任务添加失败！";
				return false;
			}
		}
		
		function modMission($postList){
			if($this->mod($postList)){
				$this->messList[] = "任务修改成功！";
				return true;
			}else{
				$this->messList[] = "任务修改失败！";
				return false;
			}
		}
		
		function delMission($id){
			$sqlwhere="mid".$this->sqlWhere($id);
			if($this->del($id)){
				if($this->verify->delVerify($id)){
					$this->messList[] = "该任务记录删除成功.";
				}
				$this->messList[] = "任务删除成功.";
				return true;
			}else{
				$this->messList[] = "任务删除失败.";
				return false;
			}
		}
		
		function getAllMission($offset,$num){
			$sql = "SELECT mid,title, murl, amount, remain, pay,etime FROM {$this->tabName} ORDER BY mid ASC LIMIT $offset, $num";
			$result=$this->mysqli->query($sql);
			while($row=$result->fetch_assoc()){
				$data[]=$row;
			}
			return $data;
		}
		
		function validateForm(){
			
		}
		
		function getRowTotal(){
			$result=$this->mysqli->query("SELECT * FROM {$this->tabName}");
			return $result->num_rows;
		}
	}
?>